//package com.lgw.gateway.filter;
//
//import org.springframework.cloud.gateway.filter.GatewayFilterChain;
//import org.springframework.cloud.gateway.filter.GlobalFilter;
//import org.springframework.core.Ordered;
//import org.springframework.http.server.reactive.ServerHttpRequest;
//import org.springframework.stereotype.Component;
//import org.springframework.web.server.ServerWebExchange;
//import reactor.core.publisher.Mono;
//
//import java.net.InetSocketAddress;
//
//@Component
//public class IpFilter implements GlobalFilter, Ordered {
//    @Override
//    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
////        System.out.println("经过第1个过滤器IpFilter");
//        ServerHttpRequest request = exchange.getRequest();
//        InetSocketAddress remoteAddress = request.getRemoteAddress();
//        System.out.println("ip:"+remoteAddress.getHostName());
//        return chain.filter(exchange);//放行
//    }
//
//    @Override
//    public int getOrder() {
//        return 1;//返回值越小,优先级越高
//    }
//}